<?php

class ActionLogin extends BaseAction
{
    public function run()
    {
        $oUser = new User('login');

        if ( Yii::app()->request->getIsPostRequest() )
        {
            $oUser->setAttributesFromRequest('aLogin');
            
            if ( $oUser->validate() )
            {
            	if (Yii::app()->user->isAdmin()) 
            	{
            		Yii::app()->controller->redirect(Yii::app()->controller->createUrl('/admin'));
            	}
            	else
            	{
            		Yii::app()->controller->redirect('/');
            	}
            }
        }

        $this->template->oUser = $oUser;
    }
}